Set Alarm
In this example, alarm functionality is demonstrated.
- Trigger alarm if heap used by Node.js exceeds 5 MB
File : setAlarm.js
const net = require('net');
const debug = require('pretty-debug');
debug.info('Example : Set Alarm');
debug.scheduleHealthCheck(function(){
debug.memoryWatermark();
debug.sysMemoryMonitor();
debug.nodeMemoryMonitor({
heapTotal: { upperLimit : 5 }
}, function(){
debug.critical('Memory Usage Alarm : Total heap usage is above 5 MB');
// Do other things like sending email!
});
}, 1);
Run Example
To run the above example simply run the command below
$ node setAlarm.js